home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CRON_1 / CRON_SET / CRON / CRON_DOC.TXT < prev    next >
Text File  |  1991-10-03  |  6KB  |  164 lines

  1.  
  2.  
  3.  
  4.     CRON
  5.     ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  6.     
  7.     
  8.     NAME
  9.         
  10.         cron - clock daemon
  11.     
  12.     
  13.     DESCRIPTION
  14.         
  15.         The cron daemon executes commands at specified dates and
  16.         times according to the instructions in the crontab file.
  17.         Since cron never exits, it should only be executed once.
  18.         This is best done by placing an alias to cron in the 
  19.         System 7 "Startup Items" folder.  Cron will then be exec-
  20.         uted automatically during system startup.
  21.         
  22.         The crontab file consists of lines of seven fields each.
  23.         The fields are separated by spaces or tabs.    The first five
  24.         fields are integer patterns that specify:
  25.         
  26.         o    Minute (0-59)
  27.         o    Hour (0-23)
  28.         o    Day of the month (1-31)
  29.         o    Month of the year (1-12)
  30.         o    Day of the week (1-7, with 1=Monday)
  31.         
  32.         Each pattern can contain:
  33.         
  34.         o    A number in the range above
  35.         o    Two numbers separated by a minus (-) sign means an
  36.             inclusive range
  37.         o    A list of numbers separated by commas means any of the
  38.             numbers
  39.         o    An asterisk (*) means all legal values
  40.         
  41.         The sixth field is a user name. This is required for compat-
  42.         ibility, but is not currently used. Supply a dummy value in
  43.         this field.
  44.         
  45.         The seventh field consists of all text on the line after the
  46.         sixth field, including tabs and spaces. This field is the
  47.         command that is executed at the specified times. If the 
  48.         seventh field begins with "-b", the command that follows will 
  49.         be executed in the background.  Otherwise, commands are 
  50.         initially launched into the forground.
  51.         
  52.         Incorrectly constructed lines are ignored. No errors are 
  53.         reported to the user.
  54.         
  55.         The crontab file is examined by cron every minute, on the
  56.         minute.
  57.         
  58.         Ultimately, cron should be setup as a faceless background task,
  59.         but for the moment, it still has a face, so it can be seen in 
  60.         and selected from System 7's application menu.  When cron is in
  61.         the foreground, hitting any key on the keyboard will cause it 
  62.         to quit.
  63.  
  64.  
  65.     NOTES
  66.         
  67.         Unlike the UNIX cron, a % character in the seventh and following
  68.         fields is not translated to a newline character.  
  69.         
  70.         Escape sequences are supported in all fields, so preceding a 
  71.         character by a backslash (\) will cause the character to be
  72.         ignored for parsing purposes.  In addition, the standard set of
  73.         escape sequences are supported:
  74.             
  75.             \a        alert (bell) character
  76.             \b        backspace
  77.             \f        formfeed
  78.             \n        newline
  79.             \r        carriage return
  80.             \t        horizontal tab
  81.             \v        vertical tab
  82.             \\        backslash
  83.             \?        question mark
  84.             \'        single quote
  85.             \"        double quote
  86.             
  87.             Hexadecimal (\xhh) and Octal (\ooo) sequences are not 
  88.             currently supported, however.
  89.         
  90.         Double quotes can be used to delimit fields.  For example, the 
  91.         file name "Captain╒s Suite" is interpreted as a single field if
  92.         it is surrounded by double quotes, but as two fields ("Captain╒s"
  93.         and "Suite") if the quotes are omitted.  The parsing code is not 
  94.         currently sensitive to single quotes.
  95.     
  96.     
  97.     CRON AS AN APPLICATION
  98.         
  99.         Ultimately, cron will be a faceless background program which 
  100.         won't appear in the application menu.  For development purposes, 
  101.         however, it's more convenient to allow it to show-up there.  It
  102.         still doesn't have any sort of user interface, but you can (at 
  103.         least) force it to quit by selecting it in the application menu 
  104.         and hitting any key.  Cron should quit immediately.
  105.         
  106.         No user interface helps guarantee that cron runs in the smallest
  107.         possible amount of memory.  It currently runs in 32K and will
  108.         probably work perfectly well in 20K.
  109.         
  110.         Any user interface that is eventually created will be a separate
  111.         program.
  112.     
  113.     
  114.     ARGUMENT PASSING
  115.         
  116.         If you are interested in writing commands for cron, read the 
  117.         following.  If not, ignore the rest of this file.
  118.         
  119.         One of the things that makes cron capable of doing useful things
  120.         is its ability to pass arguments to the programs it executes.
  121.         Since the Mac OS has virtually no provision for argument passing,
  122.         a scheme had to be invented for cron.
  123.         
  124.         Cron passes arguments to the programs it executes in a custom 
  125.         AppleEvent.  In order to get its arguments, a program must call
  126.         a routine named argcReceiver which will wait as much as one min-
  127.         ute for the appropriate AppleEvent to arrive.  If the arguments
  128.         are not received within one minute, argcReceiver calls 
  129.         ExitToShell to terminate the program.
  130.         
  131.         ArgcReceiver takes two parameters: a pointer to an argc and an 
  132.         argv variable.  The call typically looks like this:
  133.         
  134.         void main() {
  135.             int                        argc;
  136.             char                     **argv;
  137.             
  138.             argcReceiver(&argc, &argv);
  139.             
  140.         /*    Put the rest of your main procedure down here.... */
  141.             
  142.         }
  143.         
  144.         Normally, you'll call ArgcReceiver before your main does anything 
  145.         else.  Once you've made the call, argc and argv will be filled out
  146.         *exactly* as they would be in a normal C programming environment.  
  147.         So, apart from having to make this one procedure call at the start
  148.         of your main program in order to get your arguments, you can use
  149.         the arguments exactly as you're accustomed to doing so in other 
  150.         environments, like UNIX.
  151.         
  152.         Note that cron provides no support for stdin, stdout, stderr or 
  153.         exit return values.  Work is underway on a separate product that
  154.         will support all this and more, however.
  155.         
  156.         The source code for argcReceiver is in the cron folder along with
  157.         the source code for argcBuilder -- a collection of routines which
  158.         make it fast and painless to assemble and transmit the argument
  159.         AppleEvents to other programs.
  160.  
  161.  
  162.  
  163.  
  164.